"""
模型定义：

class Student(models.Model):
    name = models.CharField(max_length=20)
    sex = models.IntegerField()
    age = models.IntegerField()
    cellphone = models.CharField(max_length=20)

"""

import random
from datetime import timedelta

from django.utils import timezone

from app1.models import Student


def populate_students(names):
    for name in names:
        sex = random.choice([0,1,0,1,0,1])
        age = random.randint(18, 30)
        num = random.randint(10000000, 99999999)
        cellphone = '186%s' % num
        delta = timedelta(days=random.randint(-1800, 1800))
        birth = timezone.now() + delta
        Student.objects.create(name=name, sex=sex, age=age, birth=birth, cellphone=cellphone)
        print('inserted %s' % name)


if __name__ == '__main__':

    names = ['Aaron', 'Abbas', 'Abraham', 'Afonso', 'Albertus', 'Alexander', 'Alfonso', 'Alfred', 'Anthony', 'Antiochus', 'Arsenius', 'Ashot', 'Askia', 'Babai', 'Basil', 'Bertin', 'Bhumibol', 'Bolesław', 'Bruno', 'Casimir', 'Catherine', 'Charlemagne', 'Chlothar', 'Chulalongkorn', 'Cnut', 'Constantine', 'Cyrus', 'Darius', 'Eliezer', 'Emperor', 'Eucratides', 'Euthymius', 'Farrukhan', 'Ferdinand', 'Frederick', 'Genghis', 'Gerhard', 'Gero', 'Gertrude', 'Gustavus', 'Gwanggaeto', 'Hanno', 'Henry', 'Herod', 'Hiyya', 'Hugh', 'Humphrey', 'Ivan', 'Joannicius', 'John', 'Justinian', 'Kamehameha', 'Kangxi', 'Kanishka', 'Kublai', 'Kvirike', 'Llywelyn', 'Louis', 'Macarius', 'Mangrai', 'Manuel', 'Mircea', 'Mithridates', 'Mstislav', 'Mubarak', 'Narai', 'Naresuan', 'Odo', 'Otto', 'Parakramabahu', 'Peter', 'Photius', 'Phutthayotfa', 'Pompey', 'Pope', 'Qin', 'Radama', 'Raja', 'Ram', 'Ramesses', 'Ramon', 'Reza', 'Rhodri', 'Robert', 'Roman', 'Sancho', 'Sargon', 'Sejong', 'Shapur', 'Simeon', 'Stefan', 'Stephen', 'Tamar', 'Theoderic', 'Theodosius', 'Tigranes', 'Timur', 'Tiridates', 'Valdemar', 'Valentinian', 'Vladimir', 'William', 'Xerxes', 'Yuknoom']

    populate_students(names)
